package com.vanky.graph.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.vanky.graph.pojo.Result;
import com.vanky.graph.pojo.Vertex;
import com.vanky.graph.pojo.fqResult;
import com.vanky.graph.service.FuzzyQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/fuzzyQuery")
public class FuzzyQueryController {
    @Autowired
    private FuzzyQueryService fuzzyQueryService;

    //模糊查询所有节点用于列表展示
    @GetMapping("/all/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListAll(word);
        return Result.success(result);
    }

    //模糊查询法院节点用于列表展示
    @GetMapping("/court/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInCourtForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListCourt(word);
        return Result.success(result);
    }

    //模糊查询法官节点用于列表展示
    @GetMapping("/judge/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInJudgeForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListJudge(word);
        return Result.success(result);
    }

    //模糊查询案由节点用于列表展示
    @GetMapping("/cause/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInCauseForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListCauseType(word);
        return Result.success(result);
    }

    //模糊查询法条节点用于列表展示
    @GetMapping("/law/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInLawForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListLaw(word);
        return Result.success(result);
    }

    //模糊查询律所名称节点用于列表展示
    @GetMapping("/lawfirm/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInLawFirmForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListLawFirm(word);
        return Result.success(result);
    }

    //模糊查询律师节点用于列表展示
    @GetMapping("/lawyer/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInLawyerForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListLawyer(word);
        return Result.success(result);
    }

    //模糊查询当事人节点用于列表展示
    @GetMapping("/litigant/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInLitigantForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListLitigant(word);
        return Result.success(result);
    }

    //模糊查询案件名称节点用于列表展示
    @GetMapping("/case/list/{word}")
    public Result<List<Vertex>> getVertexByFuzzyQueryInCaseNameForList(@PathVariable String word) throws JsonProcessingException{
        List<Vertex> result=fuzzyQueryService.FuzzyQueryListCase(word);
        return Result.success(result);
    }

    //根据id模糊查询节点
    @GetMapping("/id/{id}")
    public Result<List<fqResult>> getVertexByFuzzyQueryById(@PathVariable String id) throws JsonProcessingException {
        List<fqResult> result = fuzzyQueryService.FuzzyQueryById(id);
        return Result.success(result);
    }
}
